# use normal make for this Makefile
#
# Makefile for building user programs to run on top of Nachos
#
# Several things to be aware of:
#
#    Nachos assumes that the location of the program startup routine (the
# 	location the kernel jumps to when the program initially starts up)
#       is at location 0.  This means: start.o must be the first .o passed 
# 	to ld, in order for the routine "Start" to be loaded at location 0
#

# If you are running on SunOS 5.x machines, uncomment the next line
GCCDIR = /auto/home-scf-22/csci402/testgnu/decstation-ultrix/bin/
LDFLAGS = -T newscript -N
ASFLAGS = -mips1
CPPFLAGS = $(INCDIR)

# if you aren't cross-compiling:
# GCCDIR =
# LDFLAGS = -N -T 0
# ASFLAGS =
# CPPFLAGS = -P $(INCDIR)


CC = $(GCCDIR)gcc
AS = $(GCCDIR)as
LD = $(GCCDIR)ld
CPP = $(GCCDIR)cpp

INCDIR =-I../userprog -I../threads
CFLAGS = -G 0 -c $(INCDIR)

all: halt matmult sort testfiles yield locktest locktestProc1 locktestProc2 cvtest part2test exittest train multitrain printtest train2 part3test vmtest vmfork vmtest2 mvtest c1 c2 c3 c4 c5 netsctest dtrain dtc dsteward dwaiter dchef dpsg1 dmultichef dmultiwaiter dmultipsg dmultipsgall ddiningcar dporter dca dcon dmultica dmultiporter dpsg2

start.o: start.s ../userprog/syscall.h
	$(CPP) $(CPPFLAGS) start.s > strt.s
	$(AS) $(ASFLAGS) -o start.o strt.s
	rm strt.s

halt.o: halt.c
	$(CC) $(CFLAGS) -c halt.c
halt: halt.o start.o
	$(LD) $(LDFLAGS) start.o halt.o -o halt.coff
	../bin/coff2noff halt.coff halt

sort.o: sort.c
	$(CC) $(CFLAGS) -c sort.c
sort: sort.o start.o
	$(LD) $(LDFLAGS) start.o sort.o -o sort.coff
	../bin/coff2noff sort.coff sort

matmult.o: matmult.c
	$(CC) $(CFLAGS) -c matmult.c
matmult: matmult.o start.o
	$(LD) $(LDFLAGS) start.o matmult.o -o matmult.coff
	../bin/coff2noff matmult.coff matmult

testfiles.o: testfiles.c
	$(CC) $(CFLAGS) -c testfiles.c
testfiles: testfiles.o start.o
	$(LD) $(LDFLAGS) start.o testfiles.o -o testfiles.coff
	../bin/coff2noff testfiles.coff testfiles
    
yield.o: yield.c
	$(CC) $(CFLAGS) -c yield.c
yield: yield.o start.o
	$(LD) $(LDFLAGS) start.o yield.o -o yield.coff
	../bin/coff2noff yield.coff yield
    
locktest.o: locktest.c
	$(CC) $(CFLAGS) -c locktest.c
locktest: locktest.o start.o
	$(LD) $(LDFLAGS) start.o locktest.o -o locktest.coff
	../bin/coff2noff locktest.coff locktest
    
locktestProc1.o: locktestProc1.c
	$(CC) $(CFLAGS) -c locktestProc1.c
locktestProc1: locktestProc1.o start.o
	$(LD) $(LDFLAGS) start.o locktestProc1.o -o locktestProc1.coff
	../bin/coff2noff locktestProc1.coff locktestProc1
    
locktestProc2.o: locktestProc2.c
	$(CC) $(CFLAGS) -c locktestProc2.c
locktestProc2: locktestProc2.o start.o
	$(LD) $(LDFLAGS) start.o locktestProc2.o -o locktestProc2.coff
	../bin/coff2noff locktestProc2.coff locktestProc2
    
cvtest.o: cvtest.c
	$(CC) $(CFLAGS) -c cvtest.c
cvtest: cvtest.o start.o
	$(LD) $(LDFLAGS) start.o cvtest.o -o cvtest.coff
	../bin/coff2noff cvtest.coff cvtest
    
mvtest.o: mvtest.c
	$(CC) $(CFLAGS) -c mvtest.c
mvtest: mvtest.o start.o
	$(LD) $(LDFLAGS) start.o mvtest.o -o mvtest.coff
	../bin/coff2noff mvtest.coff mvtest
	
part2test.o: part2test.c
	$(CC) $(CFLAGS) -c part2test.c
part2test: part2test.o start.o
	$(LD) $(LDFLAGS) start.o part2test.o -o part2test.coff
	../bin/coff2noff part2test.coff part2test

exittest.o: exittest.c
	$(CC) $(CFLAGS) -c exittest.c
exittest: exittest.o start.o
	$(LD) $(LDFLAGS) start.o exittest.o -o exittest.coff
	../bin/coff2noff exittest.coff exittest
    
train.o: train.c
	$(CC) $(CFLAGS) -c train.c
train: train.o start.o
	$(LD) $(LDFLAGS) start.o train.o -o train.coff
	../bin/coff2noff train.coff train
	
train2.o: train2.c
	$(CC) $(CFLAGS) -c train2.c
train2: train2.o start.o
	$(LD) $(LDFLAGS) start.o train2.o -o train2.coff
	../bin/coff2noff train2.coff train2
    
multitrain.o: multitrain.c
	$(CC) $(CFLAGS) -c multitrain.c
multitrain: multitrain.o start.o
	$(LD) $(LDFLAGS) start.o multitrain.o -o multitrain.coff
	../bin/coff2noff multitrain.coff multitrain

printtest.o: printtest.c
	$(CC) $(CFLAGS) -c printtest.c
printtest: printtest.o start.o
	$(LD) $(LDFLAGS) start.o printtest.o -o printtest.coff
	../bin/coff2noff printtest.coff printtest
    
part3test.o: part3test.c
	$(CC) $(CFLAGS) -c part3test.c
part3test: part3test.o start.o
	$(LD) $(LDFLAGS) start.o part3test.o -o part3test.coff
	../bin/coff2noff part3test.coff part3test
    
netsctest.o: netsctest.c
	$(CC) $(CFLAGS) -c netsctest.c
netsctest: netsctest.o start.o
	$(LD) $(LDFLAGS) start.o netsctest.o -o netsctest.coff
	../bin/coff2noff netsctest.coff netsctest

vmtest.o: vmtest.c
	$(CC) $(CFLAGS) -c vmtest.c
vmtest: vmtest.o start.o
	$(LD) $(LDFLAGS) start.o vmtest.o -o vmtest.coff
	../bin/coff2noff vmtest.coff vmtest
	
vmtest2.o: vmtest2.c
	$(CC) $(CFLAGS) -c vmtest2.c
vmtest2: vmtest2.o start.o
	$(LD) $(LDFLAGS) start.o vmtest2.o -o vmtest2.coff
	../bin/coff2noff vmtest2.coff vmtest2
	
vmfork.o: vmfork.c
	$(CC) $(CFLAGS) -c vmfork.c
vmfork: vmfork.o start.o
	$(LD) $(LDFLAGS) start.o vmfork.o -o vmfork.coff
	../bin/coff2noff vmfork.coff vmfork
    
c1.o: c1.c
	$(CC) $(CFLAGS) -c c1.c
c1: c1.o start.o
	$(LD) $(LDFLAGS) start.o c1.o -o c1.coff
	../bin/coff2noff c1.coff c1
    
c2.o: c2.c
	$(CC) $(CFLAGS) -c c2.c
c2: c2.o start.o
	$(LD) $(LDFLAGS) start.o c2.o -o c2.coff
	../bin/coff2noff c2.coff c2
    
c3.o: c3.c
	$(CC) $(CFLAGS) -c c3.c
c3: c3.o start.o
	$(LD) $(LDFLAGS) start.o c3.o -o c3.coff
	../bin/coff2noff c3.coff c3
    
c4.o: c4.c
	$(CC) $(CFLAGS) -c c4.c
c4: c4.o start.o
	$(LD) $(LDFLAGS) start.o c4.o -o c4.coff
	../bin/coff2noff c4.coff c4
    
c5.o: c5.c
	$(CC) $(CFLAGS) -c c5.c
c5: c5.o start.o
	$(LD) $(LDFLAGS) start.o c5.o -o c5.coff
	../bin/coff2noff c5.coff c5
	
dtrain.o: dtrain.c
	$(CC) $(CFLAGS) -c dtrain.c
dtrain: dtrain.o start.o
	$(LD) $(LDFLAGS) start.o dtrain.o -o dtrain.coff
	../bin/coff2noff dtrain.coff dtrain
	
dtc.o: dtc.c
	$(CC) $(CFLAGS) -c dtc.c
dtc: dtc.o start.o
	$(LD) $(LDFLAGS) start.o dtc.o -o dtc.coff
	../bin/coff2noff dtc.coff dtc
	
dsteward.o: dsteward.c
	$(CC) $(CFLAGS) -c dsteward.c
dsteward: dsteward.o start.o
	$(LD) $(LDFLAGS) start.o dsteward.o -o dsteward.coff
	../bin/coff2noff dsteward.coff dsteward
    
dwaiter.o: dwaiter.c
	$(CC) $(CFLAGS) -c dwaiter.c
dwaiter: dwaiter.o start.o
	$(LD) $(LDFLAGS) start.o dwaiter.o -o dwaiter.coff
	../bin/coff2noff dwaiter.coff dwaiter
    
dchef.o: dchef.c
	$(CC) $(CFLAGS) -c dchef.c
dchef: dchef.o start.o
	$(LD) $(LDFLAGS) start.o dchef.o -o dchef.coff
	../bin/coff2noff dchef.coff dchef
    
dpsg1.o: dpsg1.c
	$(CC) $(CFLAGS) -c dpsg1.c
dpsg1: dpsg1.o start.o
	$(LD) $(LDFLAGS) start.o dpsg1.o -o dpsg1.coff
	../bin/coff2noff dpsg1.coff dpsg1

dpsg2.o: dpsg2.c
	$(CC) $(CFLAGS) -c dpsg2.c
dpsg2: dpsg2.o start.o
	$(LD) $(LDFLAGS) start.o dpsg2.o -o dpsg2.coff
	../bin/coff2noff dpsg2.coff dpsg2

dmultichef.o: dmultichef.c
	$(CC) $(CFLAGS) -c dmultichef.c
dmultichef: dmultichef.o start.o
	$(LD) $(LDFLAGS) start.o dmultichef.o -o dmultichef.coff
	../bin/coff2noff dmultichef.coff dmultichef
    
dmultiwaiter.o: dmultiwaiter.c
	$(CC) $(CFLAGS) -c dmultiwaiter.c
dmultiwaiter: dmultiwaiter.o start.o
	$(LD) $(LDFLAGS) start.o dmultiwaiter.o -o dmultiwaiter.coff
	../bin/coff2noff dmultiwaiter.coff dmultiwaiter
    
dmultipsg.o: dmultipsg.c
	$(CC) $(CFLAGS) -c dmultipsg.c
dmultipsg: dmultipsg.o start.o
	$(LD) $(LDFLAGS) start.o dmultipsg.o -o dmultipsg.coff
	../bin/coff2noff dmultipsg.coff dmultipsg
    
dmultipsgall.o: dmultipsgall.c
	$(CC) $(CFLAGS) -c dmultipsgall.c
dmultipsgall: dmultipsgall.o start.o
	$(LD) $(LDFLAGS) start.o dmultipsgall.o -o dmultipsgall.coff
	../bin/coff2noff dmultipsgall.coff dmultipsgall
    
ddiningcar.o: ddiningcar.c
	$(CC) $(CFLAGS) -c ddiningcar.c
ddiningcar: ddiningcar.o start.o
	$(LD) $(LDFLAGS) start.o ddiningcar.o -o ddiningcar.coff
	../bin/coff2noff ddiningcar.coff ddiningcar

dporter.o: dporter.c
	$(CC) $(CFLAGS) -c dporter.c
dporter: dporter.o start.o
	$(LD) $(LDFLAGS) start.o dporter.o -o dporter.coff
	../bin/coff2noff dporter.coff dporter

dca.o: dca.c
	$(CC) $(CFLAGS) -c dca.c
dca: dca.o start.o
	$(LD) $(LDFLAGS) start.o dca.o -o dca.coff
	../bin/coff2noff dca.coff dca
	
dcon.o: dcon.c
	$(CC) $(CFLAGS) -c dcon.c
dcon: dcon.o start.o
	$(LD) $(LDFLAGS) start.o dcon.o -o dcon.coff
	../bin/coff2noff dcon.coff dcon

dmultica.o: dmultica.c
	$(CC) $(CFLAGS) -c dmultica.c
dmultica: dmultica.o start.o
	$(LD) $(LDFLAGS) start.o dmultica.o -o dmultica.coff
	../bin/coff2noff dmultica.coff dmultica	
	
dmultiporter.o: dmultiporter.c
	$(CC) $(CFLAGS) -c dmultiporter.c
dmultiporter: dmultiporter.o start.o
	$(LD) $(LDFLAGS) start.o dmultiporter.o -o dmultiporter.coff
	../bin/coff2noff dmultiporter.coff dmultiporter	
	
clean:
	rm -f *.o *.coff
